package com.exercise.proxytest;

import com.fun.frame.SourceCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LogProxy extends SourceCode implements IUserProvider {

    private static Logger logger = LoggerFactory.getLogger(LogProxy.class);

    private final IUserProvider userProvider;

    public LogProxy(IUserProvider userProvider) {
        this.userProvider = userProvider;
    }

    @Override
    public User getUser(int i) {
        logger.info("获取用户{}", i + EMPTY);
        return userProvider.getUser(i);
    }

    public static void main(String[] args) {
        IUserProvider userProvider = new UserProviderImpl();
        LogProxy logProxy = new LogProxy(userProvider);
        logProxy.getUser(12);
    }
}
